package com.laity.future;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;

/**
 * @author: Laity
 * @Project: JavaLaity
 * @Package: com.laity.future.Demo01
 * @Date: 2023年12月05日 11:03
 * @Description: future实现异步回调
 */

public class Demo01 {
    public static void main(String[] args) {
        // 发起一个请求
        CompletableFuture.runAsync(() -> {
            System.out.println("runAsync");
        });
        CompletableFuture.supplyAsync(() -> {
            System.out.println("supplyAsync");
            return "hello";
        }).thenAccept(System.out::println);
    }
}
